We want to have different window types for different displays, so we can
write code like this:
#if GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW (window))
{
/* do x11 stuff */
}
else
#endif
#if GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_WINDOW (window))
{
/* do wayland stuff */
}
else
#endif
{
/* do stuff for unsupported system */
}
This requires different GdkWindow types and we currently don't have
that, as only the GdkWindowImpl differs. With this method, every backend
defines a custom type that's just a simple subclass of GdkWindow. This
way GdkWindow behaves like all the other types (visuals, screens,
displays) and we can write code like the above.
object_class->dispose = gdk_display_dispose;
class->get_app_launch_context = gdk_display_real_get_app_launch_context;
+ class->window_type = GDK_TYPE_WINDOW;
/**
* GdkDisplay::opened:
GdkWindow *
_gdk_display_create_window (GdkDisplay *display)
{
- return g_object_new (GDK_TYPE_WINDOW, NULL);
+ return g_object_new (GDK_DISPLAY_GET_CLASS (display)->window_type, NULL);
}
/**
{
GObjectClass parent_class;
+ GType window_type; /* type for native windows for this display, set in class_init */
+
G_CONST_RETURN gchar * (*get_name) (GdkDisplay *display);
gint (*get_n_screens) (GdkDisplay *display);
GdkScreen * (*get_screen) (GdkDisplay *display,